﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;

namespace HotelManager
{
    public class Recepcionist : Employee, IRecepcionist
    {
        public Recepcionist(string firstName, string lastName, string address, string egn, string id, string phone, 
            string nationality, decimal salary, decimal discount)
            : base(firstName, lastName, address, egn, id, phone, nationality, salary, discount)
        {

        }

        public Recepcionist()
        {

        }

        public void CheckIn(Person guest, Room room, int duration, Engine engine)
        {
            RentInfo rentInfo = new RentInfo(guest, room, DateTime.Now, duration);

            room.Rent(rentInfo, engine);

            engine.Guests.Add(guest);
            engine.SaveData();
        }

        public void CheckOut(Person guest, Room room, Engine engine)
        {
            room.IsOccupied = false;
            room.IsClean = false;
   //         room.Minibar.Restock();

            engine.SaveData();
        }
        
        public void Reserve(Person guest, Room room, DateTime timeForCheckIn, int duration, Engine engine)
        {
            ReservationInfo reservationInfo = new ReservationInfo(guest, room, timeForCheckIn, duration);

            room.Reserve(reservationInfo, engine);

            engine.Guests.Add(guest);
            engine.SaveData();
        }

        public void CancelReservation(Person guest, Room room, Engine engine)
        {
            room.IsReserved = false;

            ReservationInfo reservationInfo = engine.ReservationHistory.Single<ReservationInfo>(r => r.Guest == guest && r.ReservedItem == room);
            reservationInfo.IsCanceled = true;

            engine.SaveData();
        }
    }
}
